﻿@using QuocHoi_TV_Frontend.Models;
@using MvcPaging;
@model List<QuocHoi_TV_Frontend.Models.News>
@{
    ViewBag.Title = "Home";
    Layout = "~/Views/Shared/_Default.cshtml";
     <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
   
    List<News> lstNewsest = ViewBag.lstlastestNews;
    List<Category> lstcatehadnews = ViewBag.lstcatehadnews;
}

<section id="content">
    <div class="ct1">
        <!-- Left Menu -->
        @Html.Partial("_leftMenu")
        <!--End Left Menu -->
        <!-- hot news -->
        <div class="showhotnews">
            <div class="boxshowhotnews">
                <div class="tilecm">
                    <span>TIN MỚI</span>
                </div>
                @{
                    News FistNews = lstNewsest[0];
                }
                <div class="showhotnewsbig">
                    <h1>
                        <a class="tileshowhotnewsbig" href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(FistNews.Category.CateName), year = DateTime.Parse(FistNews.CreateDate.ToString()).Year, month = DateTime.Parse(FistNews.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(FistNews.NewsTitle), newsID = FistNews.NewsID })">@Html.Raw(NewsHelper.Sliptsubject(FistNews.NewsTitle, 50))</a>
                    </h1>
                    <div class="imgshowhotnewsbig">
                        <a  title="@Html.Raw(FistNews.NewsTitle)" href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(FistNews.Category.CateName), year = DateTime.Parse(FistNews.CreateDate.ToString()).Year, month = DateTime.Parse(FistNews.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(FistNews.NewsTitle), newsID = FistNews.NewsID })">
                            <img class="imghnb" src="@FistNews.PathImgLarge" width="100%" height="237">
                        </a>
                    </div>
                    <p class="ctshowhotnewsbig">@Html.Raw(NewsHelper.Sliptsubject(FistNews.NewSub.ToString(), 350))
                    </p>
                    <p class="hourshowhotnewsbig">@Html.Raw(UtilDate.GetTimeSpan(DateTime.Parse(FistNews.CreateDate.ToString())))</p>

                </div>
                <div class="showhotnewssmall">
                    @{int i = 0;}
                    @foreach (News item in lstNewsest)
                    {
                        if (i > 0)
                        {
                        <div class="showhotnewssmall_1">
                            <div class="imgshowhotnewssmall">
                                <a class="imgshowhotnewssmall_1" href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(item.Category.CateName), year = DateTime.Parse(item.CreateDate.ToString()).Year, month = DateTime.Parse(item.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(item.NewsTitle), newsID = item.NewsID })">
                                    <img class="imgshns" src="@item.PathImgSmall" width="115" height="64">
                                </a>
                            </div>
                            <div class="tileshowhotnewssmall_1">
                                <p>
                                    <a href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(item.Category.CateName), year = DateTime.Parse(item.CreateDate.ToString()).Year, month = DateTime.Parse(item.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(item.NewsTitle), newsID = item.NewsID })">
                                        @Html.Raw(NewsHelper.Sliptsubject(item.NewsTitle, 80))</a>
                                </p>
                            </div>
                            <p class="hourshowhotnewsbig">@Html.Raw(UtilDate.GetTimeSpan(DateTime.Parse(item.CreateDate.ToString())))</p>
                        </div>
                        }
                        i++;
                    }
                </div>
            </div>
            <div class="btxemct">
                <a  href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(FistNews.Category.CateName), year = DateTime.Parse(FistNews.CreateDate.ToString()).Year, month = DateTime.Parse(FistNews.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(FistNews.NewsTitle), newsID = FistNews.NewsID })" >Xem tiếp</a>
            </div>
        </div>
    </div>
    <!--hotnewsofweek-->
    <div class="ct2">
        <div class="headct2">
            <div class="tilecontent">
                <a href="">Tin trong tuần </a>
            </div>
           <div class="boxweek">
						<ul class="bw" id="NewsInWeek">
                            @{int w = 0;}
                            @foreach (var itemDate in ViewBag.lstdateofweek)
                            {
                                string name = itemDate.NameDay.ToString();
                                string act = "";
                                if ((bool)itemDate.Active == true)
                                {
                                    act = "active";
                                }
                                <li class="@act" id="week_@w" onclick="changeStyle(@w)">
                                    @Ajax.ActionLink(name, "Home",
                                        new { date = itemDate.date, active = itemDate.Active},
                                        new AjaxOptions{
                                        UpdateTargetId="lstnewsbydate",
                                        InsertionMode=InsertionMode.Replace,
                                        HttpMethod="GET"
                                    })

                                </li>
                                w++;
                            }
						</ul>
					</div>
        </div>
          <div class="bodyct2" id="lstnewsbydate">
                     @{Html.RenderPartial("_NewsInWeek", Model);}
				</div>
    </div>
    @foreach (Category item in lstcatehadnews)
    {
        string strlinkcate = Url.RouteUrl("Category",
                       new
                       {
                           controller = "Categories",
                           action = "CategoriesHome",
                           cate_name = Util.RemoveSign4VietnameseString(item.CateName),
                           CategoryId = item.CateID
                       }
                        );
        <div class="ct3">
            <div class="tile_ct3">
                <div class="bg_tile_ct3">
                    <a href="@Html.Raw(strlinkcate)">@Html.Raw(item.CateName)</a>
                </div>
                @{List<Category> lstcatechild = DataModels.GetCateChildlevel1(item.CateID, 5);
                }

                <div class="nav_tile_ct3">
                    <ul>
                       
                        @foreach (Category itemchild in lstcatechild)
                        {
                            string strlinkcatesub = Url.RouteUrl("CategorySub", new
                            {
                                controller = "Categories",
                                action = "CategoriesHome",
                                cate_name = Util.RemoveSign4VietnameseString(item.CateName),
                                sub_name = Util.RemoveSign4VietnameseString(itemchild.CateName),
                                CategoryId = item.CateID
                            });
                            <li>
                                <a href="@Html.Raw(strlinkcatesub)">@Html.Raw(itemchild.CateName)</a>
                            </li>
                        }
                    </ul>
                </div>
                <div class="bg_viewall">
                    <a href="@Html.Raw(strlinkcate)">Xem tất cả tin @Html.Raw(item.CateName)</a>
                </div>
            </div>
            @{List<News> lstnewsbycate = DataModels.GetNewsByCate(item.CateID, 7);}
            <div class="linebottom">
            </div>
            <div class="xh_news">
                @{ News lastestnewsbycate = lstnewsbycate[0]; }
                <div class="bigbox_news">
                    <div class="img_bigbox_news">
                        <a href="@Url.RouteUrl("NewsDetail", new { controller = "News", action = "NewsDetailHome", cate_name = Util.RemoveSign4VietnameseString(lastestnewsbycate.Category.CateName), year = DateTime.Parse(lastestnewsbycate.CreateDate.ToString()).Year, month = DateTime.Parse(lastestnewsbycate.CreateDate.ToString()).Month, news_title = Util.RemoveSign4VietnameseString(lastestnewsbycate.NewsTitle), newsID = lastestnewsbycate.NewsID })">
                            <img src="@lastestnewsbycate.PathImgLarge" width="309" height="205">
                        </a>
                        <div class="info_bigbox_news">
                            <p>@Html.Raw(NewsHelper.Sliptsubject(lastestnewsbycate.NewsTitle, 40))</p>
                        </div>
                    </div>
                    <p>@Html.Raw(NewsHelper.Sliptsubject(lastestnewsbycate.NewSub, 140))</p>
                </div>  
                    <div class="small_news"><ul>        
                @for (int j = 1; j < lstnewsbycate.Count; j++)
                {
                    string strlinknewsbycate = Url.RouteUrl("NewsDetail",
                        new
                        {
                            controller = "News",
                            action = "NewsDetailHome",
                            cate_name = Util.RemoveSign4VietnameseString(lstnewsbycate[j].Category.CateName),
                            year = DateTime.Parse(lstnewsbycate[j].CreateDate.ToString()).Year,
                            month = DateTime.Parse(lstnewsbycate[j].CreateDate.ToString()).Month,
                            news_title = Util.RemoveSign4VietnameseString(lstnewsbycate[j].NewsTitle),
                            newsID = lstnewsbycate[j].NewsID
                        }
                         );
                    if (j <= 3)
                    {
                               <li>
                                <div class="img_sn">
                                    <a href="@Html.Raw(strlinknewsbycate)">
                                        <img src="@lstnewsbycate[j].PathImgLarge" width="117" height="73">
                                    </a>
                                </div>
                                <div class="info_sn">
                                    <a href="@Html.Raw(strlinknewsbycate)">
                                        @Html.Raw(NewsHelper.Sliptsubject(lstnewsbycate[j].NewsTitle, 40))</a>
                                    <p>@Html.Raw(lstnewsbycate[j].Category.CateName)</p>
                                </div>
                            </li>
                    }
                }</ul>  </div>  
                    <div class="small_news"><ul>        
                @for (int j = 1; j < lstnewsbycate.Count; j++)
                {
                        string  strlinknewsbycate =  Url.RouteUrl("NewsDetail", 
                            new {   controller = "News", 
                                    action = "NewsDetailHome", 
                                    cate_name = Util.RemoveSign4VietnameseString(lstnewsbycate[j].Category.CateName), 
                                    year = DateTime.Parse(lstnewsbycate[j].CreateDate.ToString()).Year, 
                                    month = DateTime.Parse(lstnewsbycate[j].CreateDate.ToString()).Month, 
                                    news_title = Util.RemoveSign4VietnameseString(lstnewsbycate[j].NewsTitle), 
                                    newsID = lstnewsbycate[j].NewsID 
                                 }
                             );
                        if (j>3)
                        {
                               <li>
                                <div class="img_sn">
                                    <a href="@Html.Raw(strlinknewsbycate)">
                                        <img src="@lstnewsbycate[j].PathImgLarge" width="117" height="73">
                                    </a>
                                </div>
                                <div class="info_sn">
                                    <a href="@Html.Raw(strlinknewsbycate)">
                                        @Html.Raw(NewsHelper.Sliptsubject(lstnewsbycate[j].NewsTitle, 40))</a>
                                    <p>@Html.Raw(lstnewsbycate[j].Category.CateName)</p>
                                </div>
                            </li>
                        }
                   }</ul>  </div>  
            </div>
        </div>
    }


</section>
<script type="text/javascript">
    function changeStyle(id) {
        if ($("#NewsInWeek li").hasClass("active")) {
            $("#NewsInWeek li").removeClass("active");
            $("#week_" + id).addClass("active");
        }
    }
</script>